<template>
  <div :style="{ width: '100%' }" class="headerContainer">
    <div class="topContainer">
      <div class="menu-left">
        <div
          v-for="(item, index) in leftList"
          :class="
            clsx(
              'menu-list',
              menuType === `${base}${item.key}` ? 'menu-action-list' : '',
              'flex items-center relative',
            )
          "
          :key="index"
        >
          <span @click="go(item)">
            {{ item.name }}
          </span>
        </div>
      </div>
      <div class="top-center">
        <img :src="Logo" alt="" style="width: 27px;height: 30px;margin-top: 2px;"/>
        <span style="font-size: 27px;">{{ title }}</span>
      </div>
      <div class="top-right">
        <weather-time-control :visible="isWeatherVisible"></weather-time-control>
        <div class="menu-right">
          <div v-for="(item, index) in rightList"
               :class="clsx('menu-list',menuType === `${base}${item.key}` ? 'menu-action-list' : '','flex items-center relative',)"
               :key="index">
            <img :src="item.image" alt="" style="width: 18px;height: 18px;margin-right: 8px"/>
            <span @click="topRightItemClick(item)">
              {{ item.name }}
            </span>
          </div>
        </div>
        <el-divider direction="vertical"></el-divider>
        <div class="top-right-manage">
          <div class="manage-box" style="align-items: center; display: flex;">
            <span style="color: #fff;">
              {{ date }}
            </span>
            <span style="color: #fff;">{{ week[day] }}</span>
            <el-divider direction="vertical"></el-divider>
            <img :src="icon3" alt="" style="width: 36px;height: 36px;"/>
            <span style="color: #c2e5ff; font-size: 12px; font-weight: 500;margin-left: 10px">温度</span>
            <span style="color: #fff;">37℃</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import bg from '@/assets/images/top.png'
import clsx from 'clsx'
import Image from '@/layout/components/BigScreenHeader/Image.png'
import xlk from '@/layout/components/BigScreenHeader/xlk.png'
import Logo from './images/logo.png'
import icon3 from './images/top-icon3.png'
import dayjs from 'dayjs'
import WeatherTimeControl from "@/views/twinScreen/weather.vue";

export default {
  name: 'TwinScreenHeader',
  components: {WeatherTimeControl},
  props: {
    title: {
      type: String,
      default: '湖南省优势特色产业集群可视化分析',
    },
    englishTitle: {
      type: String,
      default: 'Smart Garden Overview Screen',
    },
    width: {
      type: String,
      default: '100%',
    },
    leftList: {
      type: Array,
      default: () => [],
    },
    rightList: {
      type: Array,
      default: () => [],
    },
    isOpen: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      isWeatherVisible: false,
      bg,
      icon3,
      clsx,
      Image,
      xlk,
      base: '',
      menuType: '',
      menuType1: '',
      Logo,
      date: dayjs().format('YYYY.MM.DD'),
      day: dayjs().day(),
      week: [
        '星期日',
        '星期一',
        '星期二',
        '星期三',
        '星期四',
        '星期五',
        '星期六',
      ],
      isFirstMode: 0,
    }
  },
  mounted() {
    this.menuType = this.$route.path
  },
  methods: {
    topRightItemClick(item) {
      if (item.key === 'qhms') {
        this.isWeatherVisible = !this.isWeatherVisible;
      } else if (item.key === 'zymy') {
        this.isFirstMode = this.isFirstMode === 0 ? 1 : 0;
        if (window.KCDT) {
          window.KCDT.switchRoam(this.isFirstMode);
        }
      }
    },
  },
}
</script>
<style lang="scss" scoped>
@import 'css/head';

.manage-box span {
  height: 16px;
  opacity: 1;
  font-family: DIN, sans-serif;
  font-size: 16px;
  font-weight: bold;
  line-height: 16px;
  text-align: right;
  letter-spacing: 0px;
  color: #ffffff;
}

.menu-right span {
  font-size: 14px;
  font-weight: 500;
}
</style>
